home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / music / dsik_pas.zip / MANUAL.TXT < prev    next >
Text File  |  1994-09-08  |  50KB  |  1,293 lines

  1.  
  2.                   Digital Sound Interface Kit (DSIK)
  3.                            Version 1.01a
  4.                     SHAREWARE - 4 CHANNELS ONLY
  5.                         ── User's Manual ──
  6.  
  7.                        (C) 1994  Carlos Hasan
  8.  
  9.  
  10. Contents:
  11.  
  12.         1.      Introduction
  13.         1.1     What's in this Manual?
  14.         1.2     Hardware Requirements
  15.         1.3     Contacting the Author
  16.  
  17.         2.      Tutorial
  18.         2.1     Initializing DSIK
  19.         2.2     Playing Digital Samples
  20.         2.3     Playing a Music Module
  21.         2.4     Playing Sound Effects over Music
  22.  
  23.         3.      Programming Guide
  24.         3.1     Initializing DSIK
  25.         3.2     Openining Voice Channels
  26.         3.3     Mixing Voices
  27.         3.4     Playing Music
  28.         3.4.1   Loading a Module
  29.         3.4.2   Playing the Module
  30.         3.4.3   Stopping the Module
  31.         3.5     Sound Effects
  32.         3.5.1   Channels
  33.         3.5.2   Available Channels
  34.         3.5.3   Playing Sounds
  35.         3.5.4   Altering the Playing Sounds
  36.         3.6     Digital Sound Module Format
  37.         3.6.1   Converting Modules
  38.         3.7     Getting Information from DSIK
  39.         3.8     Interrupts
  40.         3.9     Using Timer Services
  41.  
  42.         4.      Reference Guide
  43.         4.1     Functions
  44.         4.2     Structures
  45.  
  46.  
  47.  
  48. Chapter 1. Introduction
  49. ─────────────────────────────────────────────────────────────────────────────
  50.  
  51.     The Digital Sound Interface Kit (DSIK) is an interface library by which
  52.     you can play digital music and sound effects on PCs, and is currently
  53.     available for Borland C++ and Borland Pascal compilers.
  54.  
  55. 1.1 What's in this Manual?
  56.  
  57.     This manual has three parts: Tutorial, Programming Guide and Reference
  58.     Guide sections. The tutorial section of this manual will show you only
  59.     the most basic functions of DSIK. You should read the Programming Guide
  60.     section to learn more about the DSIK's capabilities. For more detailed
  61.     information about every function, structure and equates defined in DSIK
  62.     you should read the Reference Guide section of this manual.
  63.  
  64. 1.2 Hardware and Software Requirements
  65.  
  66.     In order to work with DSIK you need at least an 386SX and a soundcard.
  67.     The supported soundcards are Sound Blaster, Sound Blaster Pro, Sound
  68.     Blaster 16, Gravis Ultrasound and all cards that are 100% compatible
  69.     with any of the above.
  70.     The DSIK library was compiled with Borland Pascal version 7.0, but it
  71.     should work perfectly with Turbo Pascal version 7.0.
  72.  
  73. 1.3 Contacting the Author
  74.  
  75.     If you encounter problems, find a bug in this package or want to suggest
  76.     something, use the following Internet email addresses:
  77.  
  78.         Carlos Hasan
  79.         chasan@cec.uchile.cl
  80.         cvaldovi@dcc.uchile.cl
  81.  
  82.  
  83. Chapter 2. Tutorial
  84. ─────────────────────────────────────────────────────────────────────────────
  85.  
  86.     This tutorial will show you how to use DSIK in your own applications
  87.     by providing some simple example programs. These example programs
  88.     will be built from scratch and new features will be added step by
  89.     step through the tutorial.
  90.  
  91. 2.1 Initializing DSIK
  92.  
  93.     Before using any of the DSIK's routines it has to be initialized. First
  94.     you need your soundcard hardware parameters. To ease things there is an
  95.     external program called SETUP which will ask to the user the soundcard
  96.     parameters and will save them into your disk. After, you can load these
  97.     hardware parameters from disk in your own programs. When you have all
  98.     the soundcard parameters, call the routine DSMInit to initialize the
  99.     DSIK sound system.
  100.     Now the program would be able to play sounds on different channels,
  101.     and music modules of course.
  102.  
  103.     Here is an example code for initializing DSIK:
  104.  
  105.     uses Crt,Sound;
  106.     var
  107.       Card:DSMCard;
  108.     begin
  109.       if DSMLoadSetup(Card) then begin
  110.         writeln('please run SETUP.EXE to configure.');
  111.         Halt(1);
  112.       end;
  113.       if DSMInit(Card) then begin
  114.         writeln('error initializing DSIK.');
  115.         Halt(1);
  116.       end;
  117.       :
  118.       :
  119.       DSMDone;
  120.     end.
  121.  
  122.     If everything went alright and DSMInit found the specified soundcard it
  123.     returns false. After DSMInit has initialized the system, you must call
  124.     the deinit routine DSMDone before exiting your program.
  125.  
  126. 2.2 Playing Digital Samples
  127.  
  128.     DSIK is now initialized and waits for your instructions. But first you
  129.     have to setup the amount of voices you are going to use and the master
  130.     volume level for all those channels:
  131.  
  132.     DSMSetupVoices(4,96);
  133.  
  134.     Now you have four independant channels to play sounds. To play a digital
  135.     sample (or instrument) you have to load the sample from disk, then pass
  136.     it to DSMPlaySample to start playing the sample. DSIK currently supports
  137.     standard RIFF/WAVE digital sample files which can be loaded from disk
  138.     using the routine DSMLoadSample.
  139.  
  140.     uses Crt,Sound,Load;
  141.     var
  142.       Card:DSMCard;
  143.       Drum:PDSMInst;
  144.     begin
  145.       if DSMLoadSetup(Card) or DSMInit(Card) then Halt(1);
  146.       DSMSetupVoices(4,96);
  147.       Drum := DSMLoadSample('DRUM.WAV',0);  { load sample from disk }
  148.       DSMPlaySample(0,Drum);                { play at default frequency }
  149.       while not keypressed do DSMPoll;      { wait any key }
  150.       DSMStopSample(0);                     { stop voice }
  151.       DSMFreeSample(Drum);                  { free sample from memory }
  152.       DSMDone;
  153.     end;
  154.  
  155.     The previous code loads a digital instrument from disk and plays it on
  156.     the first audio channel at the default frequency and volume.
  157.  
  158. 2.3 Playing a Music Module
  159.  
  160.     Module is a music file format first used in the Amiga computer. There are
  161.     many music formats around like: ProTracker, FastTracker, Scream Tracker,
  162.     Composer 669 and MultiTracker file formats. But DSIK only knows the DSM
  163.     module format, so to play MODs, STMs, S3Ms, 669s, and MTMs they need to
  164.     be converted into DSM format using the utility program CONV.EXE included
  165.     in the DSIK package.
  166.  
  167.     Here is an simple example program to play an DSM module:
  168.  
  169.     uses Crt,Sound,Load;
  170.     var
  171.       Card:DSMCard;
  172.       Module:PDSM;
  173.     begin
  174.       if DSMLoadSetup(Card) or DSMInit(Card) then Halt(1);
  175.       Module := DSMLoad('EXAMPLE.DSM',0);
  176.       DSMSetupVoices(Module^.Song.NumChannels,Module^.Song.MasterVolume);
  177.       DSMPlayMusic(Module);
  178.       while not keypressed do DSMPoll;
  179.       DSMStopMusic;
  180.       DSMFreeModule(Module);
  181.       DSMDone;
  182.     end;
  183.  
  184.     When running the program it should play the EXAMPLE.DSM module. If there
  185.     are problems, check that the module exists in the current directory.
  186.  
  187. 2.4 Playing Sound Effects over Music
  188.  
  189.     With DSIK it's possible to play sound effects over the music. All you have
  190.     to do is to open more channels than your module needs. The extra channels
  191.     can be used to play sound effects. Remember that DSIK always uses the first
  192.     channels from the beginning to play the music. For example, for an module
  193.     which uses 4 channels, the channels 0, 1, 2 and 3 will be used to play the
  194.     module. You can use all the unused open channels to play sound effects.
  195.  
  196.  
  197. Chapter 3. Programming Guide
  198. ─────────────────────────────────────────────────────────────────────────────
  199.  
  200.     In this section you will learn more about all the DSIK's capabilities.
  201.     It describes not only what DSIK can do, but also how. For more details
  202.     about every function and structures defined in DSIK you should read the
  203.     Reference Guide section of this manual.
  204.  
  205. 3.1 Initializing DSIK
  206.  
  207.     The first thing you should do to initialize DSIK is to get the soundcard
  208.     hardware parameters (I/O port, IRQ line, DMA channel, mixing rate). The
  209.     structure DSMCard must be filled with these parameters:
  210.  
  211.     type
  212.       DSMCard = record
  213.         CardID  : byte;             { Sound card ID }
  214.         IOAddr  : word;             { Port address  }
  215.         IRQNum  : byte;             { IRQ line      }
  216.         DRQNum  : byte;             { DMA channel   }
  217.         MixRate : word;             { Mixing rate   }
  218.       end;
  219.  
  220.     The identification number ID is unique for each card. Here is a list of
  221.     the identification numbers for the currently supported soundcards:
  222.  
  223.     const
  224.       ID_NONE     = 0;              { No soundcard       }
  225.       ID_SB       = 1;              { Sound Blaster      }
  226.       ID_SB201    = 2;              { Sound Blaster 2.01 }
  227.       ID_SBPRO    = 3;              { Sound Blaster Pro  }
  228.       ID_SB16     = 4;              { Sound Blaster 16   }
  229.       ID_GUS      = 5;              { Gravis Ultrasound  }
  230.  
  231.     There are parameters which are unused for some soundcards (for example,
  232.     the GUS soundcard does not requires the mixing rate). Also, the virtual
  233.     soundcard ID_NONE is useful for users without any sound device, because
  234.     your program can use all the DSIK functions without problems, but no
  235.     sound will be heard though.
  236.  
  237.     When the DSMCard structure is filled, call DSMInit with it and check the
  238.     returned value. If the value is false, then everything went alright and
  239.     DSIK is initialized. Otherwite an error occured.
  240.  
  241.     After initializing DSIK you should make sure that DSMDone is called upon
  242.     exit. The easiest way to do it is to use exit procedures using the Turbo
  243.     and Borland Pascal ExitProc mechanism.
  244.  
  245. 3.2 Opening Voice Channels
  246.  
  247.     Now DSIK is initialized, but you can't play any sound with it yet. First
  248.     you will have to call DSMSetupVoices to specify the amount of channel
  249.     voices your program needs and the global master volume level:
  250.  
  251.     DSMSetupVoices(8,96);
  252.  
  253.     The above code will open 8 channel voices and sets the master volume
  254.     level to 96, which is a pretty nice value for that amount of open
  255.     channels. Actually, the master volume parameter is only used in the
  256.     Sound Blaster cards and has no effect in the GUS soundcard.
  257.  
  258. 3.3 Mixing Voices
  259.  
  260.     When everything is initialized it's time to start playing some sounds.
  261.     Before any sound can be heard it has to be loaded from disk. Because
  262.     DSIK supports many more channels than your soundcard supports (except
  263.     for the GUS), DSIK has to combine many channels into a single channel.
  264.     This process is called digital mixing.
  265.  
  266.     DSIK lets you do the mixing whenever you want to do it. It does not
  267.     force you to use the timer interrupt, all that DSIK requires is to call
  268.     the function DSMPoll frequently. Actually this is not required if you are
  269.     using the GUS soundcard which uses his own interrupt service to poll the
  270.     sound system.
  271.  
  272.     To play music and sound effects in background, you only need to call
  273.     DSMPoll regularly. About 50 or 70 times per second should be enough
  274.     in most cases. For higher mixing rates you need to call this routine
  275.     more times than for lower mixing rates.
  276.  
  277.     If you want a timer interrupt to handle all the mixing, you can easily
  278.     hook the DSMPoll into a timer interrupt service:
  279.  
  280.     uses Crt,Sound,Load,TS;
  281.     var
  282.       Card:DSMCard;
  283.       Module:PDSM;
  284.     begin
  285.       if DSMLoadSetup(Card) or DSMInit(Card) then Halt(1);
  286.       TSInit;
  287.       TSSetRate(70);
  288.       TSSetRoutine(DSMPoll);
  289.       :
  290.       :
  291.       TSDone;
  292.       TSRestoreTime;
  293.       DSMDone;
  294.     end;
  295.  
  296.     The previous code will use the timer interrupt to call DSMPoll 70 times
  297.     per second. Notice that the BIOS clock will be updated while using the
  298.     timer services. Anyway, you may call TSRestoreTime to update the clock
  299.     and date (this routine uses the CMOS real time clock to update the
  300.     software BIOS clock and date).
  301.  
  302.     Here is a short summary of how to initialize DSIK:
  303.  
  304.     - Load the soundcard parameters into the DSMCard structure.
  305.     - Call DSMInit to initialize (be sure to call DSMDone before
  306.       exiting your program).
  307.     - Select the maximum number amount of simultaneos channels
  308.       and the master volume level with DSMSetupVoices.
  309.  
  310. 3.4 Playing Music
  311.  
  312.     After DSIK has been setup to play sounds, you are allowed to play music
  313.     modules. As DSIK uses his own music module format, it's necessary to use
  314.     the utility CONV.EXE to convert standard MODs, STMs, 669s, S3Ms and MTMs
  315.     to the DSM file format.
  316.  
  317. 3.4.1 Loading a Module
  318.  
  319.     Before any music can be played it has to be loaded from the disk into
  320.     system memory (and soundcard memory for the GUS driver). The module
  321.     loader is called as follows:
  322.  
  323.     Module := DSMLoad(FileName,FileOffset);
  324.  
  325.     The FileName is the full path name to the module and FileOffset is where
  326.     the module starts itself in the file (its useful if you have packed all
  327.     your module files into a huge resource file).
  328.     The loader returns a pointer to a DSM structure. If something went wrong,
  329.     NIL is returned and the global variable DSMStatus is set to one of the
  330.     following values to indicate the error occurred:
  331.  
  332.     const
  333.       ERR_OK      = 0;              { no error }
  334.       ERR_NORAM   = 1;              { not enough system memory }
  335.       ERR_NODRAM  = 2;              { not enough soundcard memory }
  336.       ERR_NOFILE  = 3;              { module/sample file not found }
  337.       ERR_FORMAT  = 4;              { invalid file format }
  338.       ERR_ACCESS  = 5;              { file corrupted }
  339.  
  340.     The DSM structure contains all the information about the module, so it
  341.     is totally possible to load multiple modules into memory.
  342.  
  343. 3.4.2 Playing the Module
  344.  
  345.     When the module has been loaded into memory it can be played with a
  346.     single function call:
  347.  
  348.     DSMPlayMusic(Module);
  349.  
  350.     The parameter is a pointer to a variable of type DSM. IF you have set up
  351.     DSIK correctly and mixing routines are called frequently, you should hear
  352.     the music playing in background. If you don't hear any music and no error
  353.     was detected, then something went wrong during initialization (probably
  354.     the soundcard hardware parameters are wrong).
  355.  
  356. 3.4.3 Stopping the Module
  357.  
  358.     If you want to stop the module which is currently being played, call the
  359.     routine DSMStopMusic. The module is always played with looping, which
  360.     means that it will never end until DSMStopMusic is called.
  361.  
  362. 3.5 Sound effects
  363.  
  364.     Playing modules in the background is a thing that can be achieved with
  365.     DSIK, but also you can play sound effects simultaneous with music.
  366.  
  367. 3.5.1 Channels
  368.  
  369.     First you need to know the amount of channels that your program will
  370.     need to play the music and sound effects. For example, if you are going
  371.     to play a 4 channels module and also you want stereo sound effects, you
  372.     need to open 6 channels (four for music and two for the sound effect
  373.     channels). To open the desired amount of channels you does:
  374.  
  375.     DSMSetupVoices(NumChannels,MasterVolume);
  376.  
  377.     The first parameter is the number of channels you want, and the second
  378.     parameter is the master volume level. DSIK currently supports up to 16
  379.     different channels, and they are zero based. That means that the first
  380.     voice channel number is 0, the second is 1, and so on.
  381.  
  382.     DSMSetupVoices can be called multiple times. However, it can't be called
  383.     while music or sound effects are being played. So be sure to stop all
  384.     the channels before changing the amount of channels.
  385.  
  386.     If you try to call DSMSetupVoices while the system is playing music or
  387.     sound effects, you will hear a small crack and the channel frequencies
  388.     will be wrong for a while if you are using the GUS soundcard.
  389.  
  390. 3.5.2 Available Channels
  391.  
  392.     You have opened six channels and DSIK is playing a four channel module,
  393.     so the channels four and five are available for your own sound effects.
  394.     DSIK always uses the first channels starting from zero, so you can be
  395.     sure that playing a sample on channel four or five will not interfere
  396.     with the music.
  397.  
  398. 3.5.3 Playing Sounds
  399.  
  400.     When you want to play a sample, you must load it from disk. The function
  401.     DSMLoadSample loads standard RIFF/WAVE files from disk. If you want to
  402.     write your own sample loader for a different sample file format, do the
  403.     following basic steps:
  404.  
  405.     - Allocate memory for the sample
  406.     - Load the sample into memory
  407.     - Create a DSMInst structure for it
  408.     - Upload the sample to the soundcard memory and release it from
  409.       system memory, if the current soundcard has on board memory.
  410.  
  411.     To learn more about how to load samples into memory, look at the DSIK
  412.     loading routine sources included in the package.
  413.  
  414.     The DSMInst structure contains all the information about a sample
  415.     instrument. Here is the definition of this structure:
  416.  
  417.     type
  418.       DSMInst = record
  419.         FileName    : array [0..12] of char;
  420.         Flags       : word;
  421.         Volume      : byte;
  422.         Length      : dword;
  423.         LoopStart   : dword;
  424.         LoopEnd     : dword;
  425.         Address     : pointer;
  426.         MidCRate    : word;
  427.         Period      : word;
  428.         SampleName  : array [0..27] of char;
  429.       end;
  430.  
  431.     After the sample has been loaded in memory, you can play it calling
  432.     the DSMPlaySample function:
  433.  
  434.     DSMPlaySample(Voice,Sample);
  435.  
  436.     where Voice is the channel number and Sample is a pointer to a DSMInst
  437.     sample structure. This function will play the sample at the default
  438.     frequency and volume specified in the DSMInst sample structure (fields
  439.     Period and Volume).
  440.  
  441.     DSIK internally uses period values instead of frequencies. The formula
  442.     to translate frequency values to periods is:
  443.  
  444.     Period = 8363*428/Hertz
  445.  
  446.     Also, DSIK uses volume levels from 0 to 64. These parameters come from
  447.     the Amiga computer and the standard MOD ProTracker file format.
  448.  
  449. 3.5.4 Altering the Playing Sounds
  450.  
  451.     Now that the sample is being played, it would be nice to change the
  452.     frequency and the volume of the sample. DSIK has functions to make it
  453.     possible. Changing the period and volume is as simple as calling:
  454.  
  455.     DSMSetPeriod(Voice,Period);
  456.     DSMSetVolume(Voice,Volume);
  457.  
  458.     Also you can change the channel panning (or balance):
  459.  
  460.     DSMSetBalance(Voice,Balance);
  461.  
  462.     where Balance is a number between 0 (left panned) and 128 (right panned),
  463.     also you can use surround effects setting the balance to 228. There some
  464.     useful equates which you can use to set the balance or panning:
  465.  
  466.     const
  467.       PAN_LEFT    = $00;            { left panning    }
  468.       PAN_RIGHT   = $80;            { right panning   }
  469.       PAN_DOLBY   = $A4;            { surround effect }
  470.  
  471.     Notice that this routine will take effect only in stereo cards, also the
  472.     surround effect works only in SB cards currently.
  473.  
  474. 3.6 Digital Sound Module Format (DSM)
  475.  
  476.     DSIK uses his own music module file format. It was designed to cope with
  477.     a variety of different module formats like MOD, STM, 669, S3M, and MTM.
  478.     It would have been very hard to write a system that supports all those
  479.     module formats, so I have made a system that supports just one format,
  480.     but with a utility to convert other module formats into this format
  481.     called Digital Sound Module Format, or DSM for short.
  482.  
  483. 3.6.1 Converting Modules
  484.  
  485.     As DSIK only supports the DSM format, you need to convert MODs, STMs,
  486.     669s, S3Ms and MTMs into DSM before playing. You can do this manually
  487.     using the CONV.EXE utility. Here is the command line syntaxis:
  488.  
  489.     CONV source[.ext] [dest[.dsm]]
  490.  
  491.     For example, CONV FEEDBACK.S3M will create the FEEDBACK.DSM module file,
  492.     which can be played with the DSIK sound system.
  493.  
  494. 3.7 Getting Information from DSIK
  495.  
  496.     DSIK can give you information about what is going on. There is a routine
  497.     called DSMGetMusicInfo which returns a pointer to the following structure
  498.     which hold a lot of useful information:
  499.  
  500.     type
  501.       DSMMusicInfo = record
  502.         ActiveTracks  : word;
  503.         Tracks        : array [0..Pred(MAXTRACKS)] of Track;
  504.         OrderPosition : byte;
  505.         OrderLength   : byte;
  506.         PatternNumber : byte;
  507.         PatternRow    : byte;
  508.         BreakFlag     : byte;
  509.         Tempo         : byte;
  510.         TempoCount    : byte;
  511.         BPM           : byte;
  512.         CardStatus    : word;
  513.         PlayStatus    : word;
  514.         SongPtr       : pointer;
  515.         SyncMark      : byte;
  516.       end;
  517.  
  518.     For synchronization with music you can use the SyncMark field. You need
  519.     to place special synchronization marks in your modules. You can use
  520.     Scream Tracker 3.01 command Z to put these marks. The command parameter
  521.     should be a byte value between 0 and 127. When DSIK encounters this
  522.     command, it sets the internal variable SyncMark with the value of the
  523.     command parameter. So the variable SyncMark always have the previous
  524.     synchronization mark value.
  525.  
  526.     With the Tracks array you get everything you need to know about what is
  527.     currently playing. The structure of each Track is defined as:
  528.  
  529.     type
  530.       Track = record
  531.         Note        : byte;
  532.         Sample      : byte;
  533.         Volume      : byte;
  534.         Effect      : word;
  535.         EQBar       : byte;
  536.       end;
  537.  
  538.     The first field is the current note playing on the track. The following
  539.     field is the current instrument number. For example, if you need to know
  540.     the name of the current instrument being played in the track, you can use
  541.     the following code:
  542.  
  543.     Name := Module^.Inst[TrackPtr^.Sample-1]^.SampleName;
  544.  
  545.     The Volume field is self explaining, and the Effect field is the current
  546.     standard Protracker command which is being interpreted.
  547.     There are other internal fields defined in the Track structure, but that
  548.     are not actually very useful for the user programs.
  549.  
  550. 3.8 Interrupts
  551.  
  552.     DSIK doesn't require interrupts. Normally you would poll DSIK in an
  553.     interrupt occuring about 50-70 times per second, which will decrease
  554.     the overhead caused by the interrupt service.
  555.  
  556. 3.9 Using Timer Services
  557.  
  558.     The Timer Service (TS) library was designed for easy handling of the
  559.     timer interrupt service. This library was included because DSIK doesn't
  560.     give you any routine to easily play music and sounds in background.
  561.     With this library you can hook your own routines to be called by the
  562.     timer interrupt service at the specified rates. For example, you can
  563.     hook the DSMPoll routine to be called 70 times per second.
  564.  
  565.     When the TS services are installed the previous BIOS service is called
  566.     at 18.2 Hz, so the BIOS clock time and date are updated normally. You
  567.     may call the routine TSRestoreTime before exiting your application to
  568.     update the BIOS clock and date if required.
  569.  
  570.     First, to initialize the TS routines you must call TSInit and be sure
  571.     to call TSDone to deinitialize the routines upon exit. Now you can hook
  572.     your own service routine with TSSetRoutine and change the timer speed:
  573.  
  574.     TSSetRoutine(MyTimer);
  575.     TSSetRate(70);
  576.  
  577.     This code setup TS to call MyTimer 70 times per second. The speed value
  578.     is given in times per seconds (or hertz) and the minimum value is 19 Hz.
  579.     Your timer service routine must preserve all the CPU registers and return
  580.     using a far stack frame (using the RETF opcode).
  581.  
  582.  
  583. Chapter 4. Reference Guide
  584. ─────────────────────────────────────────────────────────────────────────────
  585.  
  586.     This section of the manual will describe the functions, structures and
  587.     equates defined in DSIK. Functions are listed where each entry contains
  588.     a detailed description on that particular function.
  589.  
  590.  
  591. 4.1 Functions
  592.  
  593. DSMInit
  594. ─────────────────────────────────────────────────────────────────────────────
  595. Function:       Initializes the DSIK sound system.
  596.  
  597. Prototype:      function DSMInit(var Card:DSMCard):boolean;
  598.  
  599. Parameters:     Card    - Soundcard configuration structure.
  600.  
  601. Returns:        On success, returns false.
  602.                 On error, returns true.
  603.  
  604. Remarks:        This function must be called to initialize the sound
  605.                 system. When initialized you should make sure that the
  606.                 system will be deinitialized calling DSMDone upon exit.
  607.  
  608. See Also:       DSMDone.
  609.  
  610.  
  611. DSMDone
  612. ─────────────────────────────────────────────────────────────────────────────
  613. Function:       Shutdown the DSIK sound system.
  614.  
  615. Prototype:      procedure DSMDone;
  616.  
  617. Parameters:     None.
  618.  
  619. Returns:        None.
  620.  
  621. Remarks:        This function must be called to deinitialize the sound
  622.                 system upon exit. It will close all the audio channels
  623.                 and will close the current soundcard output.
  624.  
  625. See Also:       DSMInit.
  626.  
  627.  
  628. DSMPoll
  629. ─────────────────────────────────────────────────────────────────────────────
  630. Function:       Polls the DSIK sound system.
  631.  
  632. Prototype:      procedure DSMPoll;
  633.  
  634. Parameters:     None.
  635.  
  636. Returns:        None.
  637.  
  638. Remarks:        This function should be called regularly to play music
  639.                 and sound effects in background. About 50-70 times per
  640.                 second is enough in most cases.
  641.                 This routine is NOT reentrant, so if you are calling it
  642.                 in background using the timer services, do not try call
  643.                 it in foreground from your program.
  644.  
  645. See Also:       None.
  646.  
  647.  
  648. DSMSetupVoices
  649. ─────────────────────────────────────────────────────────────────────────────
  650. Function:       Setup the amount of voice channels.
  651.  
  652. Prototype:      procedure DSMSetupVoices(MaxVoices:word; MastVolume:word);
  653.  
  654. Parameters:     MaxVoices   - Number of channels to be opened
  655.                 MastVolume  - Master volume level
  656.  
  657. Returns:        None.
  658.  
  659. Remarks:        This function must be called before any sound can be
  660.                 played. You can call this function many times, but only
  661.                 while the voice channels are stopped. Currently DSIK
  662.                 supports upto 16 different channels, and the master
  663.                 volume level goes from 0 to 255. Actually the master
  664.                 volume parameter has effect only in SB soundcards.
  665.                 A recommended value for the master volume is:
  666.                     MastVolume = 384/MaxVoices
  667.                 where MaxVoices is the amount of opened channels.
  668.  
  669. See Also:       DSMInit, DSMStopVoices.
  670.  
  671.  
  672. DSMStopVoices
  673. ─────────────────────────────────────────────────────────────────────────────
  674. Function:       Stops all the voice channels.
  675.  
  676. Prototype:      procedure DSMStopVoices;
  677.  
  678. Parameters:     Note.
  679.  
  680. Returns:        None.
  681.  
  682. Remarks:        This routine will stop all the currently active voice
  683.                 channels. You should call this routine before changing
  684.                 the amount of voices with DSMSetupVoices.
  685.                 However, this routine won't stop playing the current
  686.                 music module, to do that you should call DSMStopMusic.
  687.  
  688. See Also:       DSMSetupVoices, DSMStopMusic.
  689.  
  690.  
  691. DSMTypeOfRAM
  692. ─────────────────────────────────────────────────────────────────────────────
  693. Function:       Returns the type of RAM used by the soundcard driver.
  694.  
  695. Prototype:      function DSMTypeOfRAM:word;
  696.  
  697. Parameters:     Note.
  698.  
  699. Returns:        RAM_NONE    - Driver not initialized
  700.                 RAM_SYSTEM  - Driver uses system memory
  701.                 RAM_CARD    - Driver uses soundcard memory
  702.  
  703. Remarks:        This is an internal routine used to know which kind of
  704.                 memory the soundcard uses. For example, the GUS soundcard
  705.                 uses his own soundcard memory, so the loading routines
  706.                 will upload the sample digital data to the soundcard
  707.                 and then release it from system memory.
  708.  
  709. See Also:       DSMAllocSampleData, DSMFreeSampleData.
  710.  
  711.  
  712. DSMAllocSampleData
  713. ─────────────────────────────────────────────────────────────────────────────
  714. Function:       Allocates and uploads the sample to the soundcard memory.
  715.  
  716. Prototype:      function DSMAllocSampleData(Inst:PDSMInst):boolean;
  717.  
  718. Parameters:     Inst        - Sample instrument structure
  719.  
  720. Returns:        On success, returns false.
  721.                 On error, returns true.
  722.  
  723. Remarks:        This is an internal routine used to allocate and upload
  724.                 the digital sample data to the soundcard. This function
  725.                 has no effect for soundcards which are using only system
  726.                 memory to hold digital samples.
  727.  
  728. See Also:       DSMTypeOfRAM, DSMFreeSampleData.
  729.  
  730.  
  731. DSMFreeSampleData
  732. ─────────────────────────────────────────────────────────────────────────────
  733. Function:       Frees the sample from the soundcard memory.
  734.  
  735. Prototype:      procedure DSMFreeSampleData(Inst:PDSMInst);
  736.  
  737. Parameters:     Inst        - Sample instrument structure
  738.  
  739. Returns:        None.
  740.  
  741. Remarks:        This is an internal routine used to free the sample data
  742.                 from the soundcard memory, which was allocated using the
  743.                 DSMAllocSampleData routine.
  744.  
  745. See Also:       DSMTypeOfRAM, DSMAllocSampleData.
  746.  
  747.  
  748. DSMPlaySample
  749. ─────────────────────────────────────────────────────────────────────────────
  750. Function:       Play a sample instrument.
  751.  
  752. Prototype:      procedure DSMPlaySample(Voice:word; Inst:PDSMInst);
  753.  
  754. Parameters:     Voice       - Voice channel number
  755.                 Inst        - Sample instrument structure
  756.  
  757. Returns:        None.
  758.  
  759. Remarks:        This routine will play the specified sample into the
  760.                 desired voice channel number at the default frequency
  761.                 and volume, which are included in the sample instrument
  762.                 structure (fields Period and Volume).
  763.  
  764. See Also:       DSMStopSample, DSMSetPeriod, DSMSetVolume, DSMSetBalance,
  765.                 DSMSetSoundVolume, DSMSetupVoices, DSMStopVoices.
  766.  
  767.  
  768. DSMStopSample
  769. ─────────────────────────────────────────────────────────────────────────────
  770. Function:       Stops a sample instrument.
  771.  
  772. Prototype:      procedure DSMStopSample(Voice:word);
  773.  
  774. Parameters:     Voice       - Voice channel number
  775.  
  776. Returns:        None.
  777.  
  778. Remarks:        This routine will stop the sample which is being played
  779.                 at the specified channel number.
  780.  
  781. See Also:       DSMPlaySample, DSMSetPeriod, DSMSetVolume, DSMSetBalance,
  782.                 DSMSetSoundVolume, DSMSetupVoices, DSMStopVoices.
  783.  
  784.  
  785. DSMSetPeriod
  786. ─────────────────────────────────────────────────────────────────────────────
  787. Function:       Changes the channel period value.
  788.  
  789. Prototype:      procedure DSMSetPeriod(Voice:word; Period:word);
  790.  
  791. Parameters:     Voice       - Voice channel number
  792.                 Period      - Period value (28-6848)
  793.  
  794. Returns:        None.
  795.  
  796. Remarks:        This routine will change the period of the specified voice
  797.                 channel number. You can translate frequency values in hertz
  798.                 to period values using the following formula:
  799.                     Period = 8363*428/Hertz
  800.  
  801. See Also:       DSMPlaySample, DSMStopSample, DSMSetVolume, DSMSetBalance,
  802.                 DSMSetSoundVolume, DSMSetupVoices, DSMStopVoices.
  803.  
  804.  
  805. DSMSetVolume
  806. ─────────────────────────────────────────────────────────────────────────────
  807. Function:       Changes the channel volume level.
  808.  
  809. Prototype:      procedure DSMSetVolume(Voice:word; Volume:word);
  810.  
  811. Parameters:     Voice       - Voice channel number
  812.                 Volume      - Volume level (0-64)
  813.  
  814. Returns:        None.
  815.  
  816. Remarks:        This routine will change the volume of the specified voice
  817.                 channel number. The volume level goes from 0 to 64.
  818.  
  819. See Also:       DSMPlaySample, DSMStopSample, DSMSetPeriod, DSMSetBalance,
  820.                 DSMSetSoundVolume, DSMSetupVoices, DSMStopVoices.
  821.  
  822.  
  823. DSMSetBalance
  824. ─────────────────────────────────────────────────────────────────────────────
  825. Function:       Changes the channel panning position.
  826.  
  827. Prototype:      procedure DSMSetBalance(Voice:word; Balance:word);
  828.  
  829. Parameters:     Voice       - Voice channel number
  830.                 Balance     - Vanning position (0-128,228)
  831.  
  832. Returns:        None.
  833.  
  834. Remarks:        This routine will change the panning position of the
  835.                 specified voice channel number. The panning value goes
  836.                 from $00 to $80 (left to right panning) and $A4 for
  837.                 surround effects. Here is a list of defined equates:
  838.  
  839.                 Constant    Value   Meaning
  840.                 ────────────────────────────────────
  841.                 PAN_LEFT     $00    Left panning
  842.                 PAN_RIGHT    $80    Right panning
  843.                 PAN_DOLBY    $A4    Surround effect
  844.  
  845.                 This routine has effect only in stereo soundcards.
  846.  
  847. See Also:       DSMPlaySample, DSMStopSample, DSMSetPeriod, DSMSetVolume,
  848.                 DSMSetSoundVolume, DSMSetupVoices, DSMStopVoices.
  849.  
  850.  
  851. DSMSetMusicVolume
  852. ─────────────────────────────────────────────────────────────────────────────
  853. Function:       Changes the global volume for all the music channels.
  854.  
  855. Prototype:      procedure DSMSetMusicVolume(Volume:word);
  856.  
  857. Parameters:     Volume      - Volume level (0-255)
  858.  
  859. Returns:        None.
  860.  
  861. Remarks:        This routine will change the global music volume for
  862.                 all the music channels. It's very useful to do fades
  863.                 and for games which are playing sounds over music.
  864.                 Notice that this volume level goes from 0 to 255
  865.                 (not from 0 to 64 like for individual channels).
  866.  
  867. See Also:       DSMPlayMusic, DSMSetSoundVolume, DSMSetupVoices.
  868.  
  869.  
  870. DSMSetSoundVolume
  871. ─────────────────────────────────────────────────────────────────────────────
  872. Function:       Changes the global volume for the sound effects channels.
  873.  
  874. Prototype:      procedure DSMSetSoundVolume(Volume:word);
  875.  
  876. Parameters:     Volume      - Volume level (0-255)
  877.  
  878. Returns:        None.
  879.  
  880. Remarks:        This routine will change the global sound effects volume
  881.                 for all the non-music channels. The sound effect channels
  882.                 are those which are not used to play the current music
  883.                 module.
  884.  
  885. See Also:       DSMPlayMusic, DSMSetMusicVolume, DSMSetupVoices.
  886.  
  887.  
  888. DSMPlayMusic
  889. ─────────────────────────────────────────────────────────────────────────────
  890. Function:       Start playing a music module.
  891.  
  892. Prototype:      procedure DSMPlayMusic(Module:PDSM);
  893.  
  894. Parameters:     Module      - Music module address
  895.  
  896. Returns:        None.
  897.  
  898. Remarks:        This routine will start playing the music module. You should
  899.                 be sure to have enough channels opened to play the music, or
  900.                 you won't hear some of the music track channels.
  901.  
  902. See Also:       DSMStopMusic, DSMSetMusicVolume, DSMSetupVoices.
  903.  
  904.  
  905. DSMStopMusic
  906. ─────────────────────────────────────────────────────────────────────────────
  907. Function:       Stops playing the current music module.
  908.  
  909. Prototype:      procedure DSMStopMusic;
  910.  
  911. Parameters:     Note.
  912.  
  913. Returns:        None.
  914.  
  915. Remarks:        This routine will stop playing the current music module.
  916.                 You must call this routine before calling DSMPlayMusic
  917.                 to play another music module.
  918.  
  919. See Also:       DSMPlayMusic, DSMSetMusicVolume, DSMSetupVoices.
  920.  
  921.  
  922. DSMGetMusicStatus
  923. ─────────────────────────────────────────────────────────────────────────────
  924. Function:       Returns the current playing status of the music.
  925.  
  926. Prototype:      function DSMGetMusicStatus:word;
  927.  
  928. Parameters:     Note.
  929.  
  930. Returns:        PS_STOPPED  - No music is being played
  931.                 PS_PLAYING  - Music is being played
  932.  
  933. Remarks:        None.
  934.  
  935. See Also:       DSMPlayMusic, DSMStopMusic.
  936.  
  937.  
  938. DSMGetMusicInfo
  939. ─────────────────────────────────────────────────────────────────────────────
  940. Function:       Returns the music information structure.
  941.  
  942. Prototype:      function DSMGetMusicStatus:PDSMMusicInfo;
  943.  
  944. Parameters:     Note.
  945.  
  946. Returns:        Static music information structure address.
  947.  
  948. Remarks:        This routine is useful to get all the information that
  949.                 you will need to know what is going on (tracks data,
  950.                 current pattern, tempo, speed, etc).
  951.  
  952. See Also:       DSMMusicInfo.
  953.  
  954.  
  955. DSMLoad
  956. ─────────────────────────────────────────────────────────────────────────────
  957. Function:       Loads a DSM music module from disk.
  958.  
  959. Prototype:      function DSMLoad(FileName:String; FileOffset:dword):PDSM;
  960.  
  961. Parameters:     FileName    - Full path filename
  962.                 FileOffset  - Start of the module within the file
  963.  
  964. Returns:        The module address in memory or NIL if an error occurred
  965.                 while loading it from disk.
  966.  
  967. Remarks:        This routine will load an DSM file from disk. You should
  968.                 convert different file formats like MODs, S3Ms, etc. to
  969.                 DSM files using the CONV.EXE utility.
  970.                 If something went wrong while loading the module file, this
  971.                 function returns NIL and the global variable DSMStatus is
  972.                 set to one of the following values:
  973.  
  974.                 Constant    Value   Meaning
  975.                 ────────────────────────────────────────────────
  976.                 ERR_NORAM   1       Not enough system memory
  977.                 ERR_NODRAM  2       Not enough soundcard memory
  978.                 ERR_NOFILE  3       Module file not found
  979.                 ERR_FORMAT  4       Invalid file format
  980.                 ERR_ACCESS  5       File corrupted
  981.  
  982. See Also:       DSMFree.
  983.  
  984.  
  985. DSMFree
  986. ─────────────────────────────────────────────────────────────────────────────
  987. Function:       Frees a music module from memory.
  988.  
  989. Prototype:      procedure DSMFree(Module:PDSM);
  990.  
  991. Parameters:     Module      - Music module
  992.  
  993. Returns:        None.
  994.  
  995. Remarks:        This routine will free an DSM module from memory. You
  996.                 cannot free a module while it's being played.
  997.  
  998. See Also:       DSMLoad.
  999.  
  1000.  
  1001. DSMLoadSample
  1002. ─────────────────────────────────────────────────────────────────────────────
  1003. Function:       Loads a WAVE sample instrument file from disk.
  1004.  
  1005. Prototype:      function DSMLoadSample(FileName:String;
  1006.                                     FileOffset:dword):PDSMInst;
  1007.  
  1008. Parameters:     FileName    - Full path filename
  1009.                 FileOffset  - Start of the sample within the file
  1010.  
  1011. Returns:        The sample instrument address or NIL if an error occurred
  1012.                 while loading it from disk.
  1013.  
  1014. Remarks:        This routine will loads an standard RIFF/WAVE sample file
  1015.                 from disk. You should convert other sample file formats
  1016.                 like VOC, AU, etc. to WAV using any third-party conversion
  1017.                 utility.
  1018.                 If something went wrong, the function returns NIL and the
  1019.                 global variable DSMStatus is set with the error type.
  1020.  
  1021. See Also:       DSMFreeSample, DSMLoad.
  1022.  
  1023.  
  1024. DSMFreeSample
  1025. ─────────────────────────────────────────────────────────────────────────────
  1026. Function:       Frees a sample instrument file from memory.
  1027.  
  1028. Prototype:      procedure DSMFreeSample(Inst:PDSMInst);
  1029.  
  1030. Parameters:     Inst        - Sample instrument
  1031.  
  1032. Returns:        None.
  1033.  
  1034. Remarks:        This routine will free the sample instrument from memory.
  1035.                 You cannot free it while it's being played.
  1036.  
  1037. See Also:       DSMLoadSample.
  1038.  
  1039.  
  1040. DSMLoadSetup
  1041. ─────────────────────────────────────────────────────────────────────────────
  1042. Function:       Loads the soundcard configuration file from disk.
  1043.  
  1044. Prototype:      function DSMLoadSetup(var Card:DSMCard):boolean;
  1045.  
  1046. Parameters:     Card        - Soundcard configuration structure
  1047.  
  1048. Returns:        On success, returns false.
  1049.                 On error, returns true.
  1050.  
  1051. Remarks:        This routine will loads the file called SOUND.CFG with
  1052.                 the soundcard hardware parameters. This file is created
  1053.                 with the external program SETUP.EXE, or calling the
  1054.                 function DSMSaveSetup.
  1055.  
  1056. See Also:       DSMSaveSetup.
  1057.  
  1058.  
  1059. DSMSaveSetup
  1060. ─────────────────────────────────────────────────────────────────────────────
  1061. Function:       Saves the soundcard configuration file to disk.
  1062.  
  1063. Prototype:      function DSMSaveSetup(var Card:DSMCard):boolean;
  1064.  
  1065. Parameters:     Card        - Soundcard configuration structure
  1066.  
  1067. Returns:        On success, returns false.
  1068.                 On error, returns true.
  1069.  
  1070. Remarks:        This routine will save the soundcard structure to the
  1071.                 file called SOUND.CFG.
  1072.  
  1073. See Also:       DSMLoadSetup.
  1074.  
  1075.  
  1076. 4.2 Structures
  1077.  
  1078. DSM structure
  1079. ─────────────────────────────────────────────────────────────────────────────
  1080. Declaration:    type
  1081.                   DSM = record
  1082.                     Song        : DSMSong;
  1083.                     Inst        : array [0..Pred(MAXSAMPLES)] of PDSMInst;
  1084.                     Patt        : array [0..Pred(MAXORDERS)] of PDSMPatt;
  1085.                   end;
  1086.  
  1087. Function:       DSM is a structure which holds all the information about
  1088.                 the music module loaded in memory. This structure is loaded
  1089.                 from disk by DSMLoad and is used by DSMPlayMusic.
  1090.  
  1091. Fields:         Song        - Main structure which holds the information
  1092.                               about the module music
  1093.                 Inst        - List of sample instruments used by the module
  1094.                 Patt        - List of patterns used by the module
  1095.  
  1096. See Also:       DSMSong, DSMInst, DSMLoad.
  1097.  
  1098.  
  1099. DSMSong structure
  1100. ─────────────────────────────────────────────────────────────────────────────
  1101. Declaration:    type
  1102.                   DSMSong = record
  1103.                     SongName    : array [0..27] of char;
  1104.                     Version     : word;
  1105.                     Flags       : word;
  1106.                     Pad         : dword;
  1107.                     NumOrders   : word;
  1108.                     NumSamples  : word;
  1109.                     NumPatterns : word;
  1110.                     NumChannels : word;
  1111.                     GlobalVolume: byte;
  1112.                     MasterVolume: byte;
  1113.                     InitTempo   : byte;
  1114.                     InitBPM     : byte;
  1115.                     ChanMap     : array [0..Pred(MAXTRACKS)] of byte;
  1116.                     Orders      : array [0..Pred(MAXORDERS)] of byte;
  1117.                   end;
  1118.  
  1119. Function:       This structure holds information about the module like
  1120.                 the amount of samples, patterns, orders, etc. This is
  1121.                 the main body of the music module, which uses the other
  1122.                 resources, like the samples and patterns, to interpret
  1123.                 and playback the music theme.
  1124.  
  1125. Fields:         SongName    - Name of the music module song
  1126.                 Version     - Module file format
  1127.                 Flags       - Module flags
  1128.                 NumOrders   - Length of the order list
  1129.                 NumSamples  - Number of sample instruments
  1130.                 NumPatterns - Number of pattern sheets
  1131.                 GlobVolume  - Global music volume
  1132.                 MastVolume  - Master volume
  1133.                 InitTempo   - Initial tempo value
  1134.                 InitBPM     - Initial BPM value
  1135.                 ChanMap     - Initial track's panning values
  1136.                 Orders      - Order list
  1137.  
  1138. See Also:       DSM, DSMLoad.
  1139.  
  1140.  
  1141. DSMInst structure
  1142. ─────────────────────────────────────────────────────────────────────────────
  1143. Declaration:    type
  1144.                   DSMInst = record
  1145.                     FileName    : array [0..12] of char;
  1146.                     Flags       : word;
  1147.                     Volume      : byte;
  1148.                     Length      : dword;
  1149.                     LoopStart   : dword;
  1150.                     LoopEnd     : dword;
  1151.                     Address     : pointer;
  1152.                     MidCRate    : word;
  1153.                     Period      : word;
  1154.                     SampleName  : array [0..27] of char;
  1155.                   end;
  1156.  
  1157. Function:       DSMInst is a structure which holds all the information
  1158.                 about an sample instrument. You can load individual
  1159.                 samples from disk using DSMLoadSample.
  1160.                 The sample bit flags are defined as follows:
  1161.  
  1162.                 Constant    Value   Meaning
  1163.                 ──────────────────────────────────────
  1164.                 INST_LOOPED  $01    Looping enabled
  1165.                 INST_SIGNED  $02    Signed samples
  1166.                 INST_PACKED  $04    Packed samples
  1167.  
  1168. Fields:         FileName    - File name of the sample instrument
  1169.                 Flags       - Sample bit flags.
  1170.                 Volume      - Default volume
  1171.                 Length      - Length of the sample
  1172.                 LoopStart   - Loop start point
  1173.                 LoopEnd     - Loop end point
  1174.                 Address     - Used internally to hold the address of
  1175.                               the raw sample data in system memory
  1176.                               or soundcard memory.
  1177.                 MidCRate    - Middle-C frequency finetune value
  1178.                 Period      - Default period value
  1179.                 SampleName  - Name of the sample instrument
  1180.  
  1181. See Also:       DSM, DSMLoad, DSMLoadSample, DSMPlaySample.
  1182.  
  1183.  
  1184. DSMCard structure
  1185. ─────────────────────────────────────────────────────────────────────────────
  1186. Declaration:    type
  1187.                   DSMCard = record
  1188.                     CardID      : byte;
  1189.                     Flags       : byte;
  1190.                     IOAddr      : word;
  1191.                     IRQNum      : byte;
  1192.                     DRQNum      : byte;
  1193.                     MixRate     : word;
  1194.                   end;
  1195.  
  1196. Function:       DSMCard holds the soundcard configuration parameters. This
  1197.                 structure is required by DSMInit to initialize the sound
  1198.                 system. Here is the list of supported soundcards:
  1199.  
  1200.                 Constant    Value   Soundcard Device
  1201.                 ────────────────────────────────────────
  1202.                 ID_NONE     0       None
  1203.                 ID_SB       1       Sound Blaster
  1204.                 ID_SB201    2       Sound Blaster 2.01
  1205.                 ID_SBPRO    3       Sound Blaster Pro
  1206.                 ID_SB16     4       Sound Blaster 16
  1207.                 ID_GUS      5       Gravis Ultrasound
  1208.  
  1209. Fields:         CardID      - Soundcard ID number
  1210.                 IOAddr      - I/O port address
  1211.                 IRQNum      - IRQ line
  1212.                 DRQNum      - DMA channel
  1213.                 MixRate     - Mixing rate
  1214.  
  1215. See Also:       DSMInit, DSMLoadSetup, DSMSaveSetup.
  1216.  
  1217.  
  1218. DSMMusicInfo structure
  1219. ─────────────────────────────────────────────────────────────────────────────
  1220. Declaration:    type
  1221.                   DSMMusicInfo = record
  1222.                     ActiveTracks  : word;
  1223.                     Tracks        : array [0..Pred(MAXTRACKS)] of Track;
  1224.                     OrderPosition : byte;
  1225.                     OrderLength   : byte;
  1226.                     PatternNumber : byte;
  1227.                     PatternRow    : byte;
  1228.                     BreakFlag     : byte;
  1229.                     Tempo         : byte;
  1230.                     TempoCount    : byte;
  1231.                     BPM           : byte;
  1232.                     CardStatus    : word;
  1233.                     PlayStatus    : word;
  1234.                     SongPtr       : pointer;
  1235.                     SyncMark      : byte;
  1236.                   end;
  1237.  
  1238. Function:       This structure is used internally by the system to keep
  1239.                 track of everything that is needed to play a music module.
  1240.                 You can access the static instance of this structure used
  1241.                 by the system using the function DSMGetMusicInfo.
  1242.  
  1243. Fields:         ActiveTracks    - Number of active tracks
  1244.                 Tracks          - Tracks data
  1245.                 OrderPosition   - Current playing position
  1246.                 OrderLength     - Length of the order list
  1247.                 PatternNumber   - Current playing pattern
  1248.                 PatternRow      - Current pattern row
  1249.                 BreakFlag       - Flag used to break patterns
  1250.                                   and for jump position commands
  1251.                 Tempo           - Current speed of the music
  1252.                 BPM             - Current BPM of the music
  1253.                 SyncMark        - The last synchronization mark
  1254.                                   encountered in the patterns
  1255.                 SongPtr         - Address of the playing module
  1256.  
  1257. See Also:       DSMGetMusicInfo, Track.
  1258.  
  1259.  
  1260. Track structure
  1261. ─────────────────────────────────────────────────────────────────────────────
  1262. Declaration:    type
  1263.                   Track = record
  1264.                     NoteEvent   : word;
  1265.                     VolumeEvent : byte;
  1266.                     Note        : byte;
  1267.                     Sample      : byte;
  1268.                     Volume      : byte;
  1269.                     Effect      : word;
  1270.                     Period      : word;
  1271.                     EQBar       : byte;
  1272.                     Reserved    : array [...] of byte;
  1273.                   end;
  1274.  
  1275. Function:       Track is a structure which hold all the information of
  1276.                 each music track channel. There is an array of Tracks
  1277.                 in the DSMMusicInfo structure which is used by the
  1278.                 system to interpret the music patterns.
  1279.  
  1280. Fields:         NoteEvent   - Last note and sample readed from the patterns
  1281.                 VolumeEvent - Last volume field readed from the patterns
  1282.                 Note        - Note index number
  1283.                 Sample      - Sample instrument number
  1284.                 Volume      - Volume level
  1285.                 Effect      - Effect command
  1286.                 Period      - Period value
  1287.                 EQBar       - Equalizer level
  1288.  
  1289. See Also:       DSMMusicInfo.
  1290.  
  1291.  
  1292.  
  1293.